package org.giovanolli.mumi.controller.business;

import org.giovanolli.mumi.controller.AbstractController;
import org.giovanolli.mumi.controller.AbstractModel;
import org.giovanolli.mumi.entities.Prepaid;
import org.giovanolli.mumi.entities.filter.PrepaidFilter;
import org.giovanolli.mumi.service.PrepaidService;
import org.giovanolli.mumi.service.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller("prepaidController")
public class PrepaidController extends AbstractController<Prepaid> {

	@Autowired
	private PrepaidService service;

	@Autowired
	private PrepaidModel model;

	@Override
	protected void bindEntityToModel() {
		Prepaid editedPrepaid = model.getEditedEntity();
		model.setName(editedPrepaid.getName());
	}

	@Override
	protected void bindModelToEntity() {
		Prepaid editedPrepaid = model.getEditedEntity();
		editedPrepaid.setName(model.getName().toUpperCase());
	}

	protected Class<Prepaid> getEntityClass() {
		return Prepaid.class;
	}

	@Override
	protected AbstractModel<Prepaid> getModel() {
		return model;

	}

	@Override
	protected Service<Prepaid> getService() {
		return service;
	}

	public void init() {
		super.init();
		model.setFilter(new PrepaidFilter());
	}
}
